package com.tpv.myapp.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tpv.myapp.domain.Authority;
import com.tpv.myapp.domain.User;

import java.time.Instant;
import java.util.List;
import java.util.Optional;
import java.util.Set;

/**
 * Spring Data JPA repository for the {@link User} entity.
 */
public interface UserMapper extends BaseMapper<User> {

    Optional<User> findOneByActivationKey(String activationKey);
    List<User> findAllByActivatedIsFalseAndActivationKeyIsNotNullAndCreatedDateBefore(Instant dateTime);
    Optional<User> findOneByResetKey(String resetKey);
    Optional<User> findOneByEmailIgnoreCase(String email);
    Optional<User> findOneByLogin(String login);

    Optional<User> findOneWithAuthoritiesByLogin(String login);

    Optional<User> findOneWithAuthoritiesByEmailIgnoreCase(String email);

    void insertUserAuthorities(Long id, Set<Authority> authorities);

    void deleteUserAuthorities(Long id);
}
